package com.tensquare.article.exception;

import com.tensquare.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author BAO
 * @version V1.0
 * @Package com.tensquare.article.exception
 * @date 2020/12/3 16:45
 * @description:
 */
@ControllerAdvice
@Slf4j
public class BaseExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception exception){
        log.info("exception::{}",exception.getMessage());
        exception.printStackTrace();
        return Result.fail("error:"+exception.getMessage());
    }
}
